﻿@using TinyLibraryCQRS.Presentations.Mvc3.Common;
@model IEnumerable<TinyLibraryCQRS.Presentations.Mvc3.Common.QueryServices.BookDataObject>

@{
    ViewBag.Title = "Books - Index";
}

<h2>Books</h2>

<p>
    @Html.ActionLink("Create New", "Create", AuthorizationAccountType.Admin)
</p>
<table>
    <tr>
        <th>
            Title
        </th>
        <th>
            ISBN
        </th>
        <th>
            Author
        </th>
        <th>
            Pages
        </th>
        <th>
            Inventory
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Title)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.ISBN)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Author)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Pages)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Inventory)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id = item.ID }, AuthorizationAccountType.Admin) &nbsp;
            @Html.ActionLink("Details", "Details", new { id = item.ID }) &nbsp;
            @Html.ActionLink("Borrow", "Borrow", new { id = item.ID }, new { onclick="return confirm('Are you sure to borrow this book?');" }, AuthorizationAccountType.User) &nbsp;
        </td>
    </tr>
}

</table>
